package com.link2room.soundwave.controller.manager;

import com.link2room.common.dto.result.base.BaseResultDto;
import com.link2room.common.dto.param.base.BaseL2rParamDto;
import com.link2room.soundwave.dto.param.manager.PmsHotelManagerParamDto;
import com.link2room.soundwave.dto.result.base.PmsHotelDto;
import com.link2room.soundwave.util.HandlerUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

/**
 * Created by VegetaKo on 2016/11/15.
 */
@Api(tags = "PMS酒店相关")
@RestController
@RequestMapping("/manager/PmsHotels")
public class PMSHotelManagerController {

    @ApiOperation(value ="获取未匹配酒店列表" ,response = PmsHotelDto.class)
    @RequestMapping(method = RequestMethod.GET)
    //@L2RPermissionResources(value = PMSHotels,optType = OptType.VIEW)
    public BaseResultDto listPmsHotelNotMapping(
            @RequestParam(value = "lhotelCode", required = true) String lhotelCode
    ) throws Exception{
        BaseL2rParamDto baseL2rParamDto=new BaseL2rParamDto();
        baseL2rParamDto.setLhotelCode(lhotelCode);
        BaseResultDto baseResultDto = new BaseResultDto();
        baseResultDto.setResultCode(0);
        baseResultDto.setQueryResult(HandlerUtil.pmsHotelHandler().listPmsHotelNotMappingHandler(baseL2rParamDto));
        return  baseResultDto;
    }

    @ApiOperation(value ="查询PMS匹配酒店" ,response = PmsHotelDto.class)
    @RequestMapping(value = "/PmsHotel",method = RequestMethod.GET)
    //@L2RPermissionResources(value = PMSHotels,optType = OptType.VIEW)
    public BaseResultDto getPmsHotelMapping(
            @RequestParam(value = "lhotelCode", required = true) String lhotelCode
    ) throws Exception{
        BaseL2rParamDto baseL2rParamDto=new BaseL2rParamDto();
        baseL2rParamDto.setLhotelCode(lhotelCode);
        BaseResultDto baseResultDto = new BaseResultDto();
        baseResultDto.setResultCode(0);
        baseResultDto.setResultInfo(HandlerUtil.pmsHotelHandler().findPmsHotelHandler(baseL2rParamDto));
        return  baseResultDto;
    }

    @ApiOperation(value ="保存PMS匹配酒店" )
    @RequestMapping(method = RequestMethod.POST)
    //@L2RPermissionResources(value = PMSHotels,optType = OptType.UPDATE)
    public BaseResultDto savePmsHotel(
            @RequestBody PmsHotelManagerParamDto pmsHotelManagerParamDto
    ) throws Exception{
        HandlerUtil.pmsHotelHandler().savePmsHotelHandler(pmsHotelManagerParamDto);
        BaseResultDto baseResultDto = new BaseResultDto();
        baseResultDto.setResultCode(0);
        return  baseResultDto;
    }

    @ApiOperation(value ="删除PMS匹配酒店" )
    @RequestMapping(value = "/{id}",method = RequestMethod.DELETE)
    //@L2RPermissionResources(value = PMSHotels,optType = OptType.DELETE)
    public BaseResultDto delPmsHotel(
            @PathVariable Long id
    ) throws Exception{
        BaseL2rParamDto baseL2rParamDto=new BaseL2rParamDto();
        baseL2rParamDto.setId(id);
        HandlerUtil.pmsHotelHandler().delPmsHotelHandler(baseL2rParamDto);
        BaseResultDto baseResultDto = new BaseResultDto();
        baseResultDto.setResultCode(0);
        return  baseResultDto;
    }
}
